
package com.gzbsoft.sc.modules.sys.dao;
import com.gzbsoft.sc.modules.sys.entity.SysMenu;
import org.springframework.data.ebean.annotation.Query;
import org.springframework.data.ebean.repository.EbeanRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
/**
 * 菜单管理
 *
 * @author Mark sunlightcs@gmail.com
 */
@Repository
public interface SysMenuDao extends EbeanRepository<SysMenu, Long> {
    /**
     * 根据父菜单，查询子菜单
     *
     * @param parentId 父菜单ID
     */
    @Query("select * from sys_menu")
    List<SysMenu> queryListParentId(Long parentId);
    /**
     * 获取不包含按钮的菜单列表
     */
    @Query("select * from sys_menu")
    List<SysMenu> queryNotButtonList();
    @Query("select * from sys_menu")
    List<Long> queryAllMenuId(Long userId);
    @Query(nativeQuery = true, value = "select * from sys_menu where find_in_set(:parentId, parent_ids)")
    List<SysMenu> findChildren(@Param("parentId") Long parentId);
}
